{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8af5f3f5-919d-456c-ba66-710e0bbc83d9",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "%pip install modin s3fs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3fe14f3a-67da-4c8d-a3f9-02dc7dc9c45a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-07-06T11:53:28.392766Z",
     "iopub.status.busy": "2022-07-06T11:53:28.392493Z",
     "iopub.status.idle": "2022-07-06T11:53:32.774958Z",
     "shell.execute_reply": "2022-07-06T11:53:32.774415Z",
     "shell.execute_reply.started": "2022-07-06T11:53:28.392696Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ClientContext(dashboard_url='127.0.0.1:8265', python_version='3.7.10', ray_version='1.13.0', ray_commit='e4ce38d001dbbe09cd21c497fedd03d692b2be3e', protocol_version='2022-03-16', _num_clients=6, _context_to_restore=<ray.util.client._ClientContext object at 0x7ff7a055c790>)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import ray\n",
    "\n",
    "ray.shutdown()\n",
    "ray.init(address=\"ray://localhost:10001\",\n",
    "         runtime_env={\"pip\": [\"s3fs\", \"modin\"]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d6ed3495-82be-4b91-bc62-a2b9b0c63c01",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-07-06T11:53:32.776039Z",
     "iopub.status.busy": "2022-07-06T11:53:32.775875Z",
     "iopub.status.idle": "2022-07-06T11:53:40.305332Z",
     "shell.execute_reply": "2022-07-06T11:53:40.304320Z",
     "shell.execute_reply.started": "2022-07-06T11:53:32.776019Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.33)\u001b[0m Spilled 10657 MiB, 23 objects, write throughput 205 MiB/s.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           review_id  label_id  input_ids  review_body  date\n",
      "sentiment                                                   \n",
      "-1              1845      1845       1845         1845  1845\n",
      " 0              1846      1846       1846         1846  1846\n",
      " 1              1846      1846       1846         1846  1846\n",
      "CPU times: user 1.24 s, sys: 220 ms, total: 1.46 s\n",
      "Wall time: 7.52 s\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.111)\u001b[0m Spilled 13488 MiB, 289 objects, write throughput 283 MiB/s.\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.33)\u001b[0m Spilled 15934 MiB, 24 objects, write throughput 252 MiB/s.\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.111)\u001b[0m Spilled 16739 MiB, 290 objects, write throughput 323 MiB/s.\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.33)\u001b[0m Spilled 16766 MiB, 161 objects, write throughput 262 MiB/s.\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "\n",
    "import modin.pandas as pd\n",
    "df = pd.read_csv(\"s3://dsoaws/ray/datasets/data/train/part-algo-1-womens_clothing_ecommerce_reviews.csv\")\n",
    "\n",
    "print(df.groupby(\"sentiment\").count())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9c4459b7-8d0f-4812-ae03-3b1125e7ffed",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
